Skip to content

feat(cloudflare): playground Worker and PlaygroundSite Durable Object (RFC-0036 phase 3) - #24

Merged
Madraka merged 4 commits into
mainfrom
feat/playground-worker
Oct 20, 2026
Merged

Madraka merged 4 commits into
mainfrom
feat/playground-worker

Conversation

@Madraka

@Madraka Madraka commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

RFC-0036 phase 3. Stacked: this branch contains #10 (RFC acceptance), #22 (phase 1) and #23 (phase 2) as merges; the phase-3 change is the last commit (a28c22e). Merge after those three; the diff then shrinks to that commit.

@cloudhal/cloudflare/playground

  • createPlaygroundWorker({ seed, render, deployUrl, demoMedia, limits, landingPath }) → { worker, PlaygroundSite }.
  • Worker: POST /_playground/session (signed __Host-cloudhal_try cookie, 303 → /sites), POST /_playground/reset, guard (isBlockedInPlayground) before forwarding, 1 MB request cap, SESSION_LIMIT per IP (Turnstile only after a hit), WRITE_LIMIT per session, PLAYGROUND_DAILY_SESSIONS (counter object daily:<date>), PLAYGROUND_ENABLED=false kill switch, / = landing without a session, Studio with one.
  • PlaygroundSite (SQLite DO): DoSqliteDriver + SiteGraphStore + LayeredBlobStore(FetcherBlobStore(ASSETS, demo), SqlBlobStore 8 MiB), seeded once under blockConcurrencyWhile; createApi({ playground }); alarm at min(last + 60 min, created + 120 min); Reset/alarm → deleteAll; past the cap → 410 even without the alarm; 507 when the database passes 20 MB or 500 nodes; /s/<session>/… and /media/* through the deployer's render, made private (private, no-store, noindex, no cache-tag, links rewritten under the prefix).
  • @cloudhal/astro-renderer/runtime: withRequestStore(store, siteId, fn) (AsyncLocalStorage; private headers for such pages).

RFC/ADR changes (RFC-0036 "Implementation notes", ADR-0038 amendment): the session cookie is signed (HMAC, PLAYGROUND_SECRET) — unsigned, a client could mint sessions and skip the creation limits and daily cap; Studio at the root, not /studio/*; guard answers schedules/unclassified; principal details; entry API shape; blob-store details; measured numbers.

Tests: test/playground.test.ts (sessions, prefixes, routing, kill switch, Turnstile) and test/playground-workerd.test.ts on workerd via wrangler's harness: open → edit → publish → render, reset reseeds, refused past the cap (Worker and object), 20 sessions at once in 0.44 s. Real Astro rendering is verified in the try repo with wrangler dev (phase 4).

pnpm check green locally (run alone, 18/18 tasks).

🤖 Generated with Claude Code

Madraka and others added 3 commits October 20, 2026 18:23
RFC-0036 phase 3. @cloudhal/cloudflare/playground: createPlaygroundWorker
returns the Worker and the PlaygroundSite class. Each session is one
SQLite-backed Durable Object holding the store (DoSqliteDriver, SQL blobs
over read-only demo media), the API in playground mode and the rendered
site under /s/<session>/ (private, no-store, noindex, links kept under
the prefix). The object seeds on first use, sets a 60-minute alarm capped
at 2 hours, wipes on Reset and refuses requests past the cap. The Worker
issues the host-only session cookie, applies isBlockedInPlayground, body,
rate and node/database limits, Turnstile after a limit hit, a daily cap
and the kill switch.

The cookie carries an HMAC of the ULID: unsigned, a client could mint
sessions past every creation limit. RFC-0036 gains implementation notes
for this and the other differences, ADR-0038 an amendment.

@cloudhal/astro-renderer/runtime gains withRequestStore, which renders a
request from a store the entry chooses.

Tested on workerd: open, edit, publish, render, reset, refuse past the
cap, 20 sessions at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Madraka <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 15:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Madraka
Madraka merged commit 745f51a into main Oct 20, 2026
6 checks passed
@Madraka Madraka mentioned this pull request Oct 20, 2026
Madraka added a commit that referenced this pull request Oct 20, 2026
feat(cloudflare): playground Worker and PlaygroundSite Durable Object (RFC-0036 phase 3)
Madraka added a commit that referenced this pull request Oct 20, 2026
The public playground (RFC-0036): Durable Object SQLite storage (#22),
playground mode in the API and Studio (#23), and the playground Worker
and PlaygroundSite Durable Object (#24).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Madraka <[email protected]>
@Madraka
Madraka deleted the feat/playground-worker branch October 20, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants